package com.springsecurity.demo.mapper;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.springsecurity.demo.model.entity.SysMenu;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单表 Mapper 接口
 * </p>
 *
 * @author fredyc
 * @since 2024-09-18
 */
@DS("rbactest")
public interface SysMenuMapper extends BaseMapper<SysMenu> {

    @Select("SELECT\n" +
            "  DISTINCT m.`perms`\n" +
            "FROM\n" +
            "  sys_user_role ur\n" +
            "JOIN sys_role r ON ur.`role_id` = r.`id` AND r.`status` = '0'\n" +
            "JOIN sys_role_menu rm ON r.`id` = rm.`role_id`\n" +
            "JOIN sys_menu m ON m.`id` = rm.`menu_id` AND m.`status` = '0'\n" +
            "WHERE\n" +
            "  ur.`user_id` = ${userid};")
    List<String> getMenuInfoByOneUserId(Long userid);
}
